<template>
	<view class="con">
		<view @click="tapupimg" class="flex-ju-c posire mt50">
			<image :src="user.avatarUrl?user.avatarUrl:'https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132'" class="wh160-160 ra160"></image>
			<view class="posiab wh50-50 ra50 bgfff flex-ju-c bottom0 ml100 borderf6f6f6">
				<image src="/static/paizhao.png" mode="widthFix" class="width24"></image>
			</view>
		</view>
		<view class="flex-ju-b  mt50 size28">
			<view class="flex-a-i " >
				昵称
			</view>
			<view class="flex1 text-right size28">
				<input @confirm="tapconfirm" confirm-type="done" v-model="nickName" placeholder-style="font-size:28rpx;" placeholder="输入名称"/>
			</view>
		</view>
		<view class="flex-ju-b  mt50 size28">
			<view class="flex-a-i " >
				UID
			</view>
			<view class="flex1 text-right size28">
				{{user.id}}
				<image src="/static/copy.png" mode="widthFix" class="width24"></image>
			</view>
		</view>
		
		<view @click="tapout" class="flex-ju-b  mt50 size28 colorFD2F55 bold400">退出当前账户</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:"",
				nickName:""
			}
		},
		onShow() {
			if(uni.getStorageSync('user')){
				this.user = uni.getStorageSync('user')
				this.nickName = this.user.nickName
			}
		},
		methods: {
			tapout(){
				uni.showModal({
					content:'确定要退出吗？',
					success:(res)=> {
						if(res.confirm){
							uni.setStorageSync('user','')
							uni.reLaunch({
								url:"/pages/user/index"
							})
						}
					}
				})
				
			},
			tapconfirm(){
				this.http('/api/wxUser',{
					nickname:this.nickName
				},'put').then(resd=>{
					this.toast('修改成功')
					var user = uni.getStorageSync('user')
					user.nickName = this.nickName
					uni.setStorageSync('user',user)
				})
			},
			tapupimg(){
				
				this.upimg(1).then(res=>{
					this.http('/api/wxUser',{
						avatar:res[0]
					},'put').then(resd=>{
						this.toast('修改成功')
						this.user.avatarUrl = res[0]
						var user = uni.getStorageSync('user')
						user.avatarUrl = res[0]
						uni.setStorageSync('user',user)
					})
				})
			}
		
		}
	}
</script>

<style>

</style>
